package cn.taneroom.lucene.util;  

/**
 * 转换类
 * @author TaneRoom
 * @since 2016年8月16日 上午11:35:14
 */
public class ParseUtil {

	/**
	 * 将字符串转化为double
	 * @param str
	 * @param defaultDouble
	 * @return double
	 */
	public static double parseStringToDouble(String str, double defaultDouble){
		double re = defaultDouble;
		try{
			re = Double.parseDouble(str);
		} catch (Exception e){
		}
		return re;
	}
	
	/**
	 * 将字符串转化为int
	 * @param str
	 * @param defaultInt
	 * @return int
	 */
	public static int parseStringToInt(String str, int defaultInt){
		int re = defaultInt;
		try{
			re = Integer.parseInt(str);
		} catch (Exception e){
		}
		return re;
	}
	
	/**
	 * 将字符串转化为long
	 * @param str
	 * @param defaultLong
	 * @return
	 */
	public static long parseStringToLong(String str, long defaultLong) {
		long re = defaultLong;
		try{
			re = Long.parseLong(str);
		} catch (Exception e){
		}
		return re;
	}
}
